<template>
  <div ref="main" style="width: 1200px;height:800px;margin: 0 auto;" />
</template>

<script>
import { getPieCustomerType } from '@/api/dashboard/dashboardcol'
export default {
  name: 'Dashboard',
  data() {
    return {
    }
  },
  created() {},
  mounted() {
    this.initEcharts()
    getPieCustomerType().then((response) => {
      const pieData = response.data
      this.initEcharts(pieData)
    })
  },
  methods: {
    initEcharts(pieData) {
      var myChart = this.$echarts.init(this.$refs.main)
      var option = {
        title: {
          text: '入住顾客类型分析',
          subtext: '按顾客类型',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: '占所有顾客类型的',
            type: 'pie',
            radius: '50%',
            data: pieData,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      }
      option && myChart.setOption(option)
    }
  }
}
</script>
